#ifndef SYNC_DIRECTORY_H_
#define SYNC_DIRECTORY_H_

#include "Sync_File.h"
#include "Sync_Regular_File.h"
#include "../exceptions/not_found_exception.h"

using namespace std;

class Sync_Directory;
typedef boost::shared_ptr<Sync_Directory> SyncDirPtr;

class Sync_Directory : public Sync_File, public BlockingMethod
{
public:
    Sync_Directory(boost::filesystem::path xpath);
    virtual ~Sync_Directory();

    virtual void scan(boost::shared_ptr<ScanCompletedInterface> listener);
    vector<boost::shared_ptr<Sync_Directory> > get_subdirs() const;
    vector<boost::shared_ptr<Sync_Regular_File> > get_subfiles() const;

    SyncDirPtr get_subdir(boost::filesystem::path filename);
    SyncRegularFilePtr get_subfile(boost::filesystem::path filename);

    bool add_subdir(SyncDirPtr dir);
    bool add_subfile(SyncRegularFilePtr file);


protected:
  /** Blocking Method Interface -- don't call directly !! **/
    virtual void blockingFunction();
    virtual void dispatchFunction();

private:
    void scan_raw();


private:
    vector< boost::shared_ptr<Sync_Directory> > subdirs;
    vector< boost::shared_ptr<Sync_Regular_File> > subfiles;
    vector< boost::shared_ptr<Sync_Directory> > shadow_subdirs;
    vector< boost::shared_ptr<Sync_Regular_File> > shadow_subfiles;

    bool shadow_locally;
};

#endif /* SYNC_DIRECTORY_H_ */
